<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>DragonBone</title>
  </head>

  <body>
    <canvas width="750" height="1000" id="canvas" style="width: 100%"></canvas>
    <script src="https://cdn.bootcdn.net/ajax/libs/pixi.js/4.8.7/pixi.min.js"></script>

    <script src="/dist/cdn/EVA.js"></script>
    <script src="/dist/cdn/EVA.rendererAdapter.js"></script>
    <script src="/dist/cdn/EVA.plugin.renderer.js"></script>
    <script src="/dist/cdn/EVA.plugin.renderer.img.js"></script>
    <script src="/dist/cdn/EVA.plugin.renderer.dragonbone.js"></script>
    <script>
      const {Game, GameObject, resource, RESOURCE_TYPE} = EVA;
      const {RendererSystem} = EVA.plugin.renderer;
      const {Img, ImgSystem} = EVA.plugin.renderer.img;
      const {DragonBone, DragonBoneSystem} = EVA.plugin.renderer.dragonbone;

      resource.addResource([
        {
          name: 'dragonbone',
          type: RESOURCE_TYPE.DRAGONBONE,
          src: {
            image: {
              type: 'png',
              url:
                'https://g.alicdn.com/eva-assets/eva-assets-examples/0.0.2/dragonbone/TB1RIpUBhn1gK0jSZKPXXXvUXXa-1024-1024.png',
            },
            tex: {
              type: 'json',
              url: 'https://g.alicdn.com/eva-assets/eva-assets-examples/0.0.2/dragonbone/fb18baf3a1af41a88f9d1a4426d47832.json',
            },
            ske: {
              type: 'json',
              url: 'https://g.alicdn.com/eva-assets/eva-assets-examples/0.0.2/dragonbone/c904e6867062e21123e1a44d2be2a0bf.json',
            },
          },
          preload: true,
        },
      ]);

      const game = new Game({
        systems: [
          new RendererSystem({
            canvas: document.querySelector('#canvas'),
            width: 750,
            height: 1000,
          }),
          new DragonBoneSystem(),
        ],
      });

      // 此处还在考虑如何设置默认场景的宽高
      game.scene.transform.size = {
        width: 750,
        height: 1000,
      };

      // dragonbone 的 origin 是失效的，将会按照dragonbone设计时的坐标重点定位
      const dragonBone = new GameObject('db', {
        anchor: {
          x: 0.5,
          y: 0.5,
        },
      });

      const db = dragonBone.addComponent(
        new DragonBone({
          resource: 'dragonbone',
          armatureName: 'armatureName',
        }),
      );

      db.play('newAnimation');
      game.scene.addChild(dragonBone);
    </script>
  </body>
</html>
